GrapeCity MultiRow Windows Forms Documentation
Sort(SortItem[],Int32,Int32) Method
Example 


A SortItem array.
The start row.
The end row.
Sorts the specified rows according to the SortItems.
Syntax
<FeatureAttribute(Name="Sort", Version="v5.0")>
Public Overloads Sub Sort( _
   ByVal sortItems() As SortItem, _
   ByVal startRow As Integer, _
   ByVal endRow As Integer _
) 
Dim instance As GcMultiRow
Dim sortItems() As SortItem
Dim startRow As Integer
Dim endRow As Integer
 
instance.Sort(sortItems, startRow, endRow)
[Feature(Name="Sort", Version="v5.0")]
public void Sort( 
   SortItem[] sortItems,
   int startRow,
   int endRow
)

Parameters

sortItems
A SortItem array.
startRow
The start row.
endRow
The end row.
Exceptions
ExceptionDescription
System.ArgumentNullExceptionThe sortItems parameter is a null reference (Nothing in Visual Basic).
System.ArgumentExceptionThe sortItems array has no items.
System.InvalidOperationException

This method cannot be accessed when the Template is a null reference (Nothing in Visual Basic).

-or-

VirtualMode is true and DataSource is a null reference (Nothing in Visual Basic).

System.ArgumentOutOfRangeException

The startRow is less than 0 or greater than the number of all sortable Rows minus 1.

-or-

The endRow is less than 0 or greater than the number of all sortable Rows minus 1.

Remarks

The method can sort multiple columns at the same time by using multiple SortItems.

This method allows advanced customization of the GcMultiRow sorting feature. In order to implement a highly customized sorting operation, you can write an event handler for the CellMouseClick event for ColumnHeaderCell and call this method with an instance of a class that implements the System.Collections.IComparer interface as a member of SortItem. In this case, you typically set the SortMode property to SortMode.Programmatic to disable automatic sorting and to leave room for a sorting glyph. When sorting by cells set to programmatic sort mode, you must display the sorting glyph yourself by setting the SortGlyphDirection property.

If the AllowUserToAddRows property value is true, the last row is always the last row. In this case, the sorting operator does not affect the last row (uncommitted new row).

If AllowUserToAddRows is true, the last Row is not sortable. If AllowUserToAddRows is false, all Rows are sortable.

Example
The following code example shows how to sort multiple cells in the GcMultiRow control. To run this example, create a GcMultiRow control in a form with a template. The template should contain at least two cells in the row. You can call this method in a button click event handler or form load event.
void SortByCodeMultiCells()
        {
            SortItem sortItem1 = new SortItem(0, SortOrder.Ascending);
            SortItem sortItem2 = new SortItem(1, SortOrder.Descending);

            SortItem[] sortItems = new SortItem[] { sortItem1, sortItem2 };

            this.gcMultiRow1.Sort(sortItems, 0, 0);
        }
Private Sub SortByCodeMultiCells()
        Dim sortItem1 As New SortItem(0, SortOrder.Ascending)
        Dim sortItem2 As New SortItem(1, SortOrder.Descending)

        Dim sortItems As SortItem() = New SortItem() {sortItem1, sortItem2}

        Me.gcMultiRow1.Sort(sortItems, 0, 0)
    End Sub
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

GcMultiRow Class
GcMultiRow Members
Overload List
SortItem Class

 

 


Copyright © GrapeCity, inc. All rights reserved.